package com.wlc.base.design.single;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 单例模式
 * @date 2021-09-16 16:42
 */
public class SingleDemo {
     /**
      * 恶汉式单例模式
      * */
     private static SingleDemo singleDemo = new SingleDemo();

     private SingleDemo(){
         System.out.println("私有属性初始化");
     }

     public static SingleDemo getInstance(){
         return singleDemo;
     }

    public static void main(String[] args) {
        SingleDemo s1 = SingleDemo.getInstance();
        SingleDemo s2 = SingleDemo.getInstance();
        System.out.println(s1.toString().equals(s2.toString()));
    }
}
